﻿using System.Collections.Generic;
using Castle.MicroKernel;
using Castle.MicroKernel.Registration;

namespace WindsorInitConfig {
    public static class IRegistrationExtensions {
        public static ICollection<IHandler> SimulateRegistration(this IRegistration reg) {
            using (var kernel = new DefaultKernel()) {
                kernel.Register(reg);
                return kernel.GetAssignableHandlers(typeof (object));
            }
        }

        public static ICollection<IHandler> SimulateRegistration(this IRegistration reg, IKernel kernel) {
            using (var childKernel = new DefaultKernel()) {
                kernel.AddChildKernel(childKernel);
                childKernel.Register(reg);
                return childKernel.GetAssignableHandlers(typeof(object));
            }            
        }
    }
}